package com.yanqu.road.server.cmd.activity.recallplayer;


import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.RecallPlayerProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.recallplayer.RecallPlayerModule;
import com.yanqu.road.server.protocol.GameProtocol;

@Cmd(code = GameProtocol.S_RECALL_PLAYER_CROSS_BIND_RESP, desc = "绑定结果返回回归玩家")
public class RecallPlayerBindResultResp extends AbstractCommand {
    private int bindRet;
    private String recallCode = "";

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        RecallPlayerProto.WriteRecallCodeServerRespCrossMsg respMsg = RecallPlayerProto.WriteRecallCodeServerRespCrossMsg.parseFrom(packet.getBytes());
        bindRet = respMsg.getRet();
        recallCode = respMsg.getRecallCode();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        if (bindRet == 0) {
            player.getModule(RecallPlayerModule.class).recallBindSuccess(recallCode);
        }
        player.getModule(RecallPlayerModule.class).resetPreBind();
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
